package com.rimi.controller;

import com.rimi.commons.CommonResult;
import com.rimi.model.dto.ShippingAddressDto;
import com.rimi.service.UserService;
import com.rimi.util.UserIdUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 收货地址
 */
@RestController
@CrossOrigin
@Api(description = "收货地址",tags = "查询默认的收货地址")
public class ShippingAddressController {

    @Autowired
    UserService userService;

    @GetMapping("/user/shoppingaddress")
    @ApiOperation("查询默认的收货地址")
    public CommonResult<List<ShippingAddressDto>> findDefaultAddress(){
        //获取当前用户ID
        Integer userId = UserIdUtil.getUserId();
        //查询地址
        return userService.findDefaultAddress(userId);
    }
}
